-- 修改所有引用supplier表的外键约束，将删除行为设置为NO ACTION
DECLARE @sql NVARCHAR(MAX) = '';

SELECT @sql += 'ALTER TABLE ' + QUOTENAME(OBJECT_SCHEMA_NAME(fk.parent_object_id)) + '.' + QUOTENAME(OBJECT_NAME(fk.parent_object_id)) + 
' DROP CONSTRAINT ' + QUOTENAME(fk.name) + ';
' +
'ALTER TABLE ' + QUOTENAME(OBJECT_SCHEMA_NAME(fk.parent_object_id)) + '.' + QUOTENAME(OBJECT_NAME(fk.parent_object_id)) + 
' ADD CONSTRAINT ' + QUOTENAME(fk.name) + ' FOREIGN KEY(' + c.name + ') REFERENCES ' + 
QUOTENAME(OBJECT_SCHEMA_NAME(fk.referenced_object_id)) + '.' + QUOTENAME(OBJECT_NAME(fk.referenced_object_id)) + '(' + rc.name + ') ON DELETE NO ACTION ON UPDATE NO ACTION;
'
FROM
    sys.foreign_keys fk
INNER JOIN
    sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id
INNER JOIN
    sys.columns c ON fkc.parent_object_id = c.object_id AND fkc.parent_column_id = c.column_id
INNER JOIN
    sys.columns rc ON fkc.referenced_object_id = rc.object_id AND fkc.referenced_column_id = rc.column_id
WHERE
    OBJECT_NAME(fk.referenced_object_id) = 'supplier';

-- 执行生成的SQL语句
EXEC sp_executesql @sql;